//引入封装好的接口
import {secklist} from '../../../request/api.js'
const state = {
    msList:[],  
} 
const getters = {
    //返回商品管理列表
    getMsList(state){
        return state.msList
    },
    //返回总数
    getCount(state){
        return state.count
    },
    //返回当前显示条数
    getSize(state){
        return state.size
    }
}
const mutations = {
    REQ_SPECSLIST(state,payload){
        state.msList = payload
    },
  
} 
const actions = {
    //封装一个秒杀列表的行动
    getMsListAction(context){
        secklist( )
        .then(res=>{
            console.log(res,'ms列表');
            if(res.code==200){
                context.commit('REQ_SPECSLIST',res.list)
               if(context.state.page !=1 && res.list.length==0 ){
                   context.dispatch('changePageAction',context.state.page-1)
               }
            }
        })
    },
   
} 


export default {
    state,
    getters,
    mutations,
    actions,
    namespaced:true
}